# -*- coding: utf-8 -*-

from utils.operators.latest_only_spark_submit_operator import LatestOnlySparkSubmitOperator
from jms.aigroup.ai_group.yl_cn_lmdm_sys_network_check import jms_aigroup__yl_cn_lmdm_sys_network
from jms.aigroup.ai_dwd.yl_threesegcode_sign import jms_ai_dwd__yl_threesegcode_sign



ai_group_guarantees_signed_threecode2es = LatestOnlySparkSubmitOperator(
    task_id='ai_group_guarantees_signed_threecode2es',
    conn_id='spark_default',
    email=['yushuo@jtexpress.com','yl_bigdata@yl-scm.com'],
    pool_slots=6,
    task_concurrency=1,  # 如果任务不支持并发，则将 task_concurrency 设为 1
    name='ai_group_guarantees_signed_threecode2es{{ execution_date | date_add(1) | cst_ds }}',  # yarn 任务名称
    yarn_queue='pyspark',
    driver_memory='4G',
    executor_memory='4G',
    executor_cores=2,
    num_executors=8,
    conf={'spark.executor.memoryOverhead': 2048,
          'spark.core.connection.ack.wait.timeout': 300,
          'spark.default.parallelism': 1500,
          'spark.locality.wait': 60,
          'spark.default.paralleism': '600',  # spark.default.parallelism只有在处理RDD时有效.
          'spark.sql.shuffle.partitions': 400,  # spark.sql.shuffle.partitions则是只对SparkSQL有效
          },
    hiveconf={'hive.exec.dynamic.partition': 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions': 100000,
              'hive.exec.max.dynamic.partitions.pernode': 100000,
              },
    java_class='com.yunlu.bigdata.jobs.ml.SignedThreesegcode2esForML ',  # spark 主类
    # application='hdfs:///user/spark/work/aigroup/yl_threesegcode_sign/jobs-1.0-SNAPSHOT-jar-with-dependencies.jar',
    application='hdfs:///scheduler/jms/spark/sou1yu/guarantees_signed_threecode2es/jobs-1.0-SNAPSHOT-jar-with-dependencies.jar',
    # spark jar 包
    application_args=['{{ execution_date | cst_ds_nodash }}'],
)


# 设置依赖
ai_group_guarantees_signed_threecode2es << [
    jms_aigroup__yl_cn_lmdm_sys_network,
    jms_ai_dwd__yl_threesegcode_sign
]
